package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.VideoChannels;
import com.ruoyi.business.service.IVideoChannelsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摄像头通道实例Controller
 * 
 * @author asher
 * @date 2021-12-05
 */
@RestController
@RequestMapping("/business/video_channels")
public class VideoChannelsController extends BaseController
{
    @Autowired
    private IVideoChannelsService videoChannelsService;

    /**
     * 查询摄像头通道实例列表
     */
    @PreAuthorize("@ss.hasPermi('business:video_channels:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoChannels videoChannels)
    {
        startPage();
        List<VideoChannels> list = videoChannelsService.selectVideoChannelsList(videoChannels);
        return getDataTable(list);
    }

    /**
     * 导出摄像头通道实例列表
     */
    @PreAuthorize("@ss.hasPermi('business:video_channels:export')")
    @Log(title = "摄像头通道实例", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VideoChannels videoChannels)
    {
        List<VideoChannels> list = videoChannelsService.selectVideoChannelsList(videoChannels);
        ExcelUtil<VideoChannels> util = new ExcelUtil<VideoChannels>(VideoChannels.class);
        return util.exportExcel(list, "摄像头通道实例数据");
    }

    /**
     * 获取摄像头通道实例详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:video_channels:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(videoChannelsService.selectVideoChannelsById(id));
    }

    /**
     * 新增摄像头通道实例
     */
    @PreAuthorize("@ss.hasPermi('business:video_channels:add')")
    @Log(title = "摄像头通道实例", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoChannels videoChannels)
    {
        return toAjax(videoChannelsService.insertVideoChannels(videoChannels));
    }

    /**
     * 修改摄像头通道实例
     */
    @PreAuthorize("@ss.hasPermi('business:video_channels:edit')")
    @Log(title = "摄像头通道实例", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoChannels videoChannels)
    {
        return toAjax(videoChannelsService.updateVideoChannels(videoChannels));
    }

    /**
     * 删除摄像头通道实例
     */
    @PreAuthorize("@ss.hasPermi('business:video_channels:remove')")
    @Log(title = "摄像头通道实例", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoChannelsService.deleteVideoChannelsByIds(ids));
    }
}
